<?php

namespace app\index\controller;

use app\index\model\SubCategory;
use app\index\model\SupCategory;
use app\index\service\CategoryService;
use app\index\service\QuotaService;
use app\index\service\UrlService;
use think\Controller;
use think\Request;

class Quota extends BaseController
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        //
        $category_list = CategoryService::getSupCategoryList();
        $url_list = UrlService::getIndexThirdUrlList();
        $this->assign("category_list",$category_list);
        $this->assign("thirdurl_list",$url_list);
        $this->assign("idIndex","1");
        $this->fetch("public/header");
        $this->fetch("public/footer");
        return $this->fetch("getPrice",["idIndex"=>"1"]);
    }
    public function getDeitail($options){
        $category_list = CategoryService::getSupCategoryList();
        $url_list = UrlService::getIndexThirdUrlList();

        $this->assign("category_list",$category_list);
        $this->assign("thirdurl_list",$url_list);
        $quota_detail = QuotaService::getMutilQuotaDetail($options);
        $this->assign("quota_detail",$quota_detail);
        $year = config("app.year");

        return $this->fetch("getPriceDt",[
            "options"=>$options,"idIndex"=>1,"year"=>$year]);
    }
    
    public function getDeitailList($options){
        $category_list = CategoryService::getSupCategoryList();
        $url_list = UrlService::getIndexThirdUrlList();
        $this->assign("category_list",$category_list);
        $this->assign("thirdurl_list",$url_list);
        $option_array = explode("-",$options);
        $supCateId=$option_array[0];
        $subCateId = $option_array[1];
        $quota_list = QuotaService::getSubCateQuotaList($subCateId);
        $this->assign("quota_list",$quota_list);
        $supcategory_name = SupCategory::getCategoryNameById($supCateId);
        $subcategory_name = SubCategory::getCategoryNameById($subCateId);
        return $this->fetch("getPriceDtList",["supCateId"=>$supCateId,
        "subCateId"=>$subCateId,"idIndex"=>"1","supcategory_name"=>$supcategory_name,
            "subcategory_name"=>$subcategory_name
        ]);

    }
    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {
        //
    }

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        //
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id)
    {
        //
    }

    /**
     * 显示编辑资源表单页.
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        //
    }
}
